home *** CD-ROM | disk | FTP | other *** search
- /*
- * Copyright 1993, 1995, Silicon Graphics, Inc.
- * All Rights Reserved.
- *
- * This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
- * the contents of this file may not be disclosed to third parties, copied or
- * duplicated in any form, in whole or in part, without the prior written
- * permission of Silicon Graphics, Inc.
- *
- * RESTRICTED RIGHTS LEGEND:
- * Use, duplication or disclosure by the Government is subject to restrictions
- * as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
- * and Computer Software clause at DFARS 252.227-7013, and/or in similar or
- * successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
- * rights reserved under the Copyright Laws of the United States.
- */
-
- /*
- * accpersp.c
- * This file contains functions for performing jittering.
- *
- */
-
- #include <GL/gl.h>
- #include <GL/glu.h>
- #include <math.h>
-
- GLvoid accFrustum(GLdouble, GLdouble, GLdouble, GLdouble,
- GLdouble, GLdouble, GLdouble, GLdouble,
- GLdouble, GLdouble, GLdouble);
- GLvoid accPerspective(GLdouble, GLdouble, GLdouble, GLdouble,
- GLdouble, GLdouble, GLdouble, GLdouble, GLdouble);
-
- /* accFrustum()
- * The first 6 arguments are identical to the glFrustum() call.
- *
- * pixdx and pixdy are anti-alias jitter in pixels.
- * Set both equal to 0.0 for no anti-alias jitter.
- *
- * eyedx and eyedy are depth-of field jitter in pixels.
- * Set both equal to 0.0 for no depth of field effects.
- *
- * focus is distance from eye to plane in focus.
- * focus must be greater than, but not equal to 0.0.
- *
- * Note that accFrustum() calls glTranslatef(). You will
- * probably want to insure that your ModelView matrix has been
- * initialized to identity before calling accFrustum().
- */
- void accFrustum(GLdouble left, GLdouble right, GLdouble bottom, GLdouble top,
- GLdouble near, GLdouble far, GLdouble pixdx, GLdouble pixdy,
- GLdouble eyedx, GLdouble eyedy, GLdouble focus)
- {
- GLdouble xwsize, ywsize;
- GLdouble dx, dy;
- GLint viewport[4];
-
- xwsize = right - left;
- ywsize = top - bottom;
-
- glGetIntegerv (GL_VIEWPORT, viewport);
- dx = -(pixdx*xwsize/(GLdouble) viewport[2] +
- eyedx*near/focus);
- dy = -(pixdy*ywsize/(GLdouble) viewport[3] +
- eyedy*near/focus);
-
- glMatrixMode(GL_PROJECTION);
- glLoadIdentity();
- glFrustum (left + dx, right + dx, bottom + dy, top + dy, near, far);
- glMatrixMode(GL_MODELVIEW);
- glLoadIdentity();
- glTranslatef (-eyedx, -eyedy, 0.0);
- }
-
- /* accPerspective()
- *
- * The first 4 arguments are identical to the gluPerspective()
- * call.
- *
- * pixdx and pixdy are anti-alias jitter in pixels.
- * Set both equal to 0.0 for no anti-alias jitter.
- *
- * eyedx and eyedy are depth-of field jitter in pixels.
- * Set both equal to 0.0 for no depth of field effects.
- *
- * focus is distance from eye to plane in focus.
- * focus must be greater than, but not equal to 0.0.
- *
- * Note that accPerspective() calls accFrustum().
- */
- void accPerspective(GLdouble fovy, GLdouble aspect,
- GLdouble near, GLdouble far, GLdouble pixdx, GLdouble pixdy,
- GLdouble eyedx, GLdouble eyedy, GLdouble focus)
- {
- GLdouble fov2,left,right,bottom,top;
-
- fov2 = ((fovy*M_PI) / 180.0) / 2.0;
-
- top = near / (cos(fov2) / sin(fov2));
- bottom = -top;
-
- right = top * aspect;
- left = -right;
-
- accFrustum (left, right, bottom, top, near, far,
- pixdx, pixdy, eyedx, eyedy, focus);
- }
-